/*
 * Kinect_BioMecView.java
 */
package kinect_biomec;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import kinect_biomec.Logic.ControlKinect;

/**
 * The application's main frame.
 */
enum camStatus {

    on, off;
}

public class Kinect_BioMecView extends FrameView{

    public ControlKinect control = new ControlKinect();

    
    public void updateKinect() {
        progressBar.setValue(25);
        control.initContext(true,
                false,
                mirrorImageSelectionBox.isSelected(),
                sceneImageSelectionBox.isSelected(),
                justShowUserSelectionBox.isSelected(), skeletonChoise, centroDeMass2DSelection.isSelected(),
                centroDeMass3DSelection.isSelected(), 
                centroDeMassMembrosSelection.isSelected(),recordingSelectionButton.isSelected());
        progressBar.setValue(100);
    }

    
    public Kinect_BioMecView(SingleFrameApplication app) {
        super(app);

        initComponents();
        painel.add(control.kinectView);

        updateKinect();
        new Thread(new infoUpdater(this)).start();
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = Kinect_BioMecApp.getApplication().getMainFrame();
            aboutBox = new Kinect_BioMecAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        Kinect_BioMecApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        barraFerramentas = new javax.swing.JToolBar();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        recordingSelectionButton = new javax.swing.JToggleButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        dimensionButton = new javax.swing.JToggleButton();
        abortCalibrationButton = new javax.swing.JButton();
        painel = new java.awt.Panel();
        jScrollPane1 = new javax.swing.JScrollPane();
        infoPainel = new javax.swing.JTextPane();
        jSeparator4 = new javax.swing.JSeparator();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        OptionsMenu = new javax.swing.JMenu();
        videoMenu = new javax.swing.JMenu();
        mirrorImageSelectionBox = new javax.swing.JCheckBoxMenuItem();
        justShowUserSelectionBox = new javax.swing.JCheckBoxMenuItem();
        sceneImageSelectionBox = new javax.swing.JCheckBoxMenuItem();
        jMenu1 = new javax.swing.JMenu();
        noneSkelButton = new javax.swing.JRadioButtonMenuItem();
        justHandAndHeadButton = new javax.swing.JRadioButtonMenuItem();
        justLowerSkelButton = new javax.swing.JRadioButtonMenuItem();
        justHigherSkelButton = new javax.swing.JRadioButtonMenuItem();
        allSkelButton = new javax.swing.JRadioButtonMenuItem();
        menuOpcoes = new javax.swing.JMenuItem();
        centroDeMassMenu = new javax.swing.JMenu();
        centroDeMass2DSelection = new javax.swing.JCheckBoxMenuItem();
        centroDeMass3DSelection = new javax.swing.JCheckBoxMenuItem();
        centroDeMassMembrosSelection = new javax.swing.JCheckBoxMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        info = new javax.swing.JLabel();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(720, 480));

        barraFerramentas.setFloatable(false);
        barraFerramentas.setRollover(true);
        barraFerramentas.setName("barraFerramentas"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N
        barraFerramentas.add(jSeparator1);

        recordingSelectionButton.setText("Gravar");
        recordingSelectionButton.setFocusable(false);
        recordingSelectionButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        recordingSelectionButton.setName("recordingSelectionButton"); // NOI18N
        recordingSelectionButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        recordingSelectionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                recordingSelectionButtonActionPerformed(evt);
            }
        });
        barraFerramentas.add(recordingSelectionButton);

        jSeparator3.setName("jSeparator3"); // NOI18N
        barraFerramentas.add(jSeparator3);

        dimensionButton.setText("3D");
        dimensionButton.setFocusable(false);
        dimensionButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        dimensionButton.setName("dimensionButton"); // NOI18N
        dimensionButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        dimensionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dimensionButtonActionPerformed(evt);
            }
        });
        barraFerramentas.add(dimensionButton);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(kinect_biomec.Kinect_BioMecApp.class).getContext().getResourceMap(Kinect_BioMecView.class);
        dimensionButton.getAccessibleContext().setAccessibleName(resourceMap.getString("dimensionButton.AccessibleContext.accessibleName")); // NOI18N

        abortCalibrationButton.setText("Abortar calibração");
        abortCalibrationButton.setFocusable(false);
        abortCalibrationButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        abortCalibrationButton.setName("abortCalibrationButton"); // NOI18N
        abortCalibrationButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        abortCalibrationButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                abortCalibrationButtonActionPerformed(evt);
            }
        });
        barraFerramentas.add(abortCalibrationButton);
        abortCalibrationButton.getAccessibleContext().setAccessibleName(resourceMap.getString("abortCalibrationButton.AccessibleContext.accessibleName")); // NOI18N

        painel.setName("painel"); // NOI18N

        javax.swing.GroupLayout painelLayout = new javax.swing.GroupLayout(painel);
        painel.setLayout(painelLayout);
        painelLayout.setHorizontalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 500, Short.MAX_VALUE)
        );
        painelLayout.setVerticalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 263, Short.MAX_VALUE)
        );

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        infoPainel.setEditable(false);
        infoPainel.setName("infoPainel"); // NOI18N
        jScrollPane1.setViewportView(infoPainel);

        jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator4.setName("jSeparator4"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentas, javax.swing.GroupLayout.DEFAULT_SIZE, 727, Short.MAX_VALUE)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(painel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(barraFerramentas, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)
                        .addContainerGap())
                    .addComponent(painel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText("Arquivo");
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(kinect_biomec.Kinect_BioMecApp.class).getContext().getActionMap(Kinect_BioMecView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        OptionsMenu.setText("Opções");
        OptionsMenu.setName("OptionsMenu"); // NOI18N

        videoMenu.setText("Video");
        videoMenu.setName("videoMenu"); // NOI18N

        mirrorImageSelectionBox.setSelected(true);
        mirrorImageSelectionBox.setText("Imagem espelhada");
        mirrorImageSelectionBox.setName("mirrorImageSelectionBox"); // NOI18N
        mirrorImageSelectionBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mirrorImageSelectionBoxActionPerformed(evt);
            }
        });
        videoMenu.add(mirrorImageSelectionBox);

        justShowUserSelectionBox.setText("Mostrar apenas o usuario");
        justShowUserSelectionBox.setName("justShowUserSelectionBox"); // NOI18N
        justShowUserSelectionBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                justShowUserSelectionBoxStateChanged(evt);
            }
        });
        justShowUserSelectionBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                justShowUserSelectionBoxActionPerformed(evt);
            }
        });
        videoMenu.add(justShowUserSelectionBox);

        sceneImageSelectionBox.setText("Colorir usuarios");
        sceneImageSelectionBox.setName("sceneImageSelectionBox"); // NOI18N
        sceneImageSelectionBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sceneImageSelectionBoxStateChanged(evt);
            }
        });
        sceneImageSelectionBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sceneImageSelectionBoxActionPerformed(evt);
            }
        });
        videoMenu.add(sceneImageSelectionBox);

        OptionsMenu.add(videoMenu);

        jMenu1.setText("Captura do esqueleto");
        jMenu1.setName("jMenu1"); // NOI18N

        noneSkelButton.setText("Não capturar");
        noneSkelButton.setName("noneSkelButton"); // NOI18N
        noneSkelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                noneSkelButtonActionPerformed(evt);
            }
        });
        jMenu1.add(noneSkelButton);

        justHandAndHeadButton.setText("Cabeça e mãos");
        justHandAndHeadButton.setName("justHandAndHeadButton"); // NOI18N
        justHandAndHeadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                justHandAndHeadButtonActionPerformed(evt);
            }
        });
        jMenu1.add(justHandAndHeadButton);

        justLowerSkelButton.setText("Parte Inferior");
        justLowerSkelButton.setName("justLowerSkelButton"); // NOI18N
        justLowerSkelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                justLowerSkelButtonActionPerformed(evt);
            }
        });
        jMenu1.add(justLowerSkelButton);

        justHigherSkelButton.setText("Parte superior");
        justHigherSkelButton.setName("justHigherSkelButton"); // NOI18N
        justHigherSkelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                justHigherSkelButtonActionPerformed(evt);
            }
        });
        jMenu1.add(justHigherSkelButton);

        allSkelButton.setSelected(true);
        allSkelButton.setText("Todo corpo");
        allSkelButton.setName("allSkelButton"); // NOI18N
        allSkelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                allSkelButtonActionPerformed(evt);
            }
        });
        jMenu1.add(allSkelButton);

        menuOpcoes.setText("Mais opções");
        menuOpcoes.setName("menuOpcoes"); // NOI18N
        menuOpcoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuOpcoesActionPerformed(evt);
            }
        });
        jMenu1.add(menuOpcoes);

        OptionsMenu.add(jMenu1);

        centroDeMassMenu.setText("Centro de massas");
        centroDeMassMenu.setName("centroDeMassMenu"); // NOI18N
        centroDeMassMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                centroDeMassMenuActionPerformed(evt);
            }
        });

        centroDeMass2DSelection.setText("Ativar centro de massa (2D)");
        centroDeMass2DSelection.setName("centroDeMass2DSelection"); // NOI18N
        centroDeMass2DSelection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                centroDeMass2DSelectionActionPerformed(evt);
            }
        });
        centroDeMassMenu.add(centroDeMass2DSelection);

        centroDeMass3DSelection.setText("Ativar centro de massa (3D)");
        centroDeMass3DSelection.setName("centroDeMass3DSelection"); // NOI18N
        centroDeMass3DSelection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                centroDeMass3DSelectionActionPerformed(evt);
            }
        });
        centroDeMassMenu.add(centroDeMass3DSelection);

        centroDeMassMembrosSelection.setText("Ativar centro de massa dos membros (2D)");
        centroDeMassMembrosSelection.setName("centroDeMassMembrosSelection"); // NOI18N
        centroDeMassMembrosSelection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                centroDeMassMembrosSelectionActionPerformed(evt);
            }
        });
        centroDeMassMenu.add(centroDeMassMembrosSelection);

        OptionsMenu.add(centroDeMassMenu);

        menuBar.add(OptionsMenu);

        helpMenu.setText("Ajuda");
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        info.setText("Info");
        info.setName("info"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(statusMessageLabel)
                    .addComponent(info))
                .addGap(18, 18, 18)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(statusAnimationLabel)
                        .addContainerGap())))
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addComponent(info))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void sceneImageSelectionBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sceneImageSelectionBoxStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_sceneImageSelectionBoxStateChanged

    private void justShowUserSelectionBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_justShowUserSelectionBoxStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_justShowUserSelectionBoxStateChanged

    private void mirrorImageSelectionBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mirrorImageSelectionBoxActionPerformed
        updateKinect();
    }//GEN-LAST:event_mirrorImageSelectionBoxActionPerformed

    private void justShowUserSelectionBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_justShowUserSelectionBoxActionPerformed
        updateKinect();
    }//GEN-LAST:event_justShowUserSelectionBoxActionPerformed

    private void sceneImageSelectionBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sceneImageSelectionBoxActionPerformed
        updateKinect();
    }//GEN-LAST:event_sceneImageSelectionBoxActionPerformed

    private void desselecionarTodosSkel() {
        noneSkelButton.setSelected(false);
        justHandAndHeadButton.setSelected(false);
        justLowerSkelButton.setSelected(false);
        justHigherSkelButton.setSelected(false);
        allSkelButton.setSelected(false);
    }
    int skeletonChoise = 2;
    private void noneSkelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noneSkelButtonActionPerformed
        skeletonChoise = 1;
        desselecionarTodosSkel();
        noneSkelButton.setSelected(true);
        updateKinect();
    }//GEN-LAST:event_noneSkelButtonActionPerformed

    private void justHandAndHeadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_justHandAndHeadButtonActionPerformed
        skeletonChoise = 5;
        desselecionarTodosSkel();
        justHandAndHeadButton.setSelected(true);
        updateKinect();
    }//GEN-LAST:event_justHandAndHeadButtonActionPerformed

    private void justLowerSkelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_justLowerSkelButtonActionPerformed
        skeletonChoise = 4;
        desselecionarTodosSkel();
        justLowerSkelButton.setSelected(true);
        updateKinect();
    }//GEN-LAST:event_justLowerSkelButtonActionPerformed

    private void justHigherSkelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_justHigherSkelButtonActionPerformed
        skeletonChoise = 3;
        desselecionarTodosSkel();
        justHigherSkelButton.setSelected(true);
        updateKinect();
    }//GEN-LAST:event_justHigherSkelButtonActionPerformed

    private void allSkelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allSkelButtonActionPerformed
        skeletonChoise = 2;
        desselecionarTodosSkel();
        allSkelButton.setSelected(true);
        updateKinect();
    }//GEN-LAST:event_allSkelButtonActionPerformed

private void centroDeMassMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_centroDeMassMenuActionPerformed
}//GEN-LAST:event_centroDeMassMenuActionPerformed

private void centroDeMass3DSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_centroDeMass3DSelectionActionPerformed
    updateKinect();
}//GEN-LAST:event_centroDeMass3DSelectionActionPerformed

private void centroDeMassMembrosSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_centroDeMassMembrosSelectionActionPerformed
    updateKinect();
}//GEN-LAST:event_centroDeMassMembrosSelectionActionPerformed

private void centroDeMass2DSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_centroDeMass2DSelectionActionPerformed
    updateKinect();
}//GEN-LAST:event_centroDeMass2DSelectionActionPerformed
    boolean is3D = false;
private void dimensionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dimensionButtonActionPerformed
    if (is3D) {
        control.startViewKinect();
        updateKinect();
        control.kinectView3D.stop();
        painel.removeAll();
        painel.add(control.kinectView);

        is3D = false;
    } else {
        control.startViewKinect3D();
        control.initContext3D(true, true, skeletonChoise, true);
        painel.removeAll();
        control.kinectView.stop();
        painel.add(control.kinectView3D);
        is3D = true;
    }
}//GEN-LAST:event_dimensionButtonActionPerformed

private void abortCalibrationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_abortCalibrationButtonActionPerformed
    control.abortCalibration();
}//GEN-LAST:event_abortCalibrationButtonActionPerformed

private void menuOpcoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpcoesActionPerformed
    new OptionsSkel(control).show();
}//GEN-LAST:event_menuOpcoesActionPerformed

private void recordingSelectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recordingSelectionButtonActionPerformed
    updateKinect();
}//GEN-LAST:event_recordingSelectionButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu OptionsMenu;
    private javax.swing.JButton abortCalibrationButton;
    private javax.swing.JRadioButtonMenuItem allSkelButton;
    private javax.swing.JToolBar barraFerramentas;
    private javax.swing.JCheckBoxMenuItem centroDeMass2DSelection;
    private javax.swing.JCheckBoxMenuItem centroDeMass3DSelection;
    private javax.swing.JCheckBoxMenuItem centroDeMassMembrosSelection;
    private javax.swing.JMenu centroDeMassMenu;
    private javax.swing.JToggleButton dimensionButton;
    public javax.swing.JLabel info;
    private javax.swing.JTextPane infoPainel;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JRadioButtonMenuItem justHandAndHeadButton;
    private javax.swing.JRadioButtonMenuItem justHigherSkelButton;
    private javax.swing.JRadioButtonMenuItem justLowerSkelButton;
    private javax.swing.JCheckBoxMenuItem justShowUserSelectionBox;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem menuOpcoes;
    private javax.swing.JCheckBoxMenuItem mirrorImageSelectionBox;
    private javax.swing.JRadioButtonMenuItem noneSkelButton;
    private java.awt.Panel painel;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JToggleButton recordingSelectionButton;
    private javax.swing.JCheckBoxMenuItem sceneImageSelectionBox;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JMenu videoMenu;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;

    public JTextPane getInfoPainel(){
        return infoPainel;
    }
}
